package ru.technogeek.labs.dreamnote.storage;

import java.util.Comparator;
import ru.technogeek.labs.dreamnote.data.ItemDbAdapter;
import ru.technogeek.labs.dreamnote.theme.ThemesManager.FilterID;

public class ItemComparator implements Comparator<ItemDbAdapter> {
	
	int filterId;
	public ItemComparator (int filterId) {
		super();
		this.filterId = filterId;
	}

	public int compare(ItemDbAdapter object1, ItemDbAdapter object2) {
		switch(filterId){
		case FilterID.priority:
			if(object1.getPriority() > object2.getPriority())
				return 1;
			else if (object1.getPriority() < object2.getPriority())
				return -1;
			return 0;
			
		case FilterID.urgency:
			if(object1.getUrgency() > object2.getUrgency())
				return 1;
			else if (object1.getUrgency() < object2.getUrgency())
				return -1;
			return 0;

		case FilterID.name:
			return object1.getDisplayText().compareTo(object2.getDisplayText());
			
		case FilterID.begins:
			return object1.getFireDate().compareTo(object2.getFireDate());
			
		case FilterID.created:
			return object1.getCreationDate().compareTo(object2.getCreationDate());
		default:
			break;
		}	
		return 0;
	}

}
